/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.documents.main.action;

import com.documents.common.core.PageBean;
import com.documents.common.core.action.BaseActionSupport;
import com.documents.pojo.ContentType;
import com.documents.service.knowledge.ContentTypeService;
import java.util.List;
import org.apache.struts2.interceptor.ServletRequestAware;

/**
 *
 * @author Administrator
 */
public class ContentTypeAction extends BaseActionSupport implements ServletRequestAware{
    
    
    private static final long serialVersionUID = 1005L;
    private ContentTypeService ContentTypeService;
    private List<ContentType>  allContentType; 
    private int page=1;
    private PageBean pageBean;
    private int pageSize = 20;
    private ContentType contentType; 
    private String actionURI;

    public String getActionURI() {
        return actionURI;
    }

    public void setActionURI(String actionURI) {
        this.actionURI = actionURI;
    }

    
    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public PageBean getPageBean() {
        return pageBean;
    }

    public void setPageBean(PageBean pageBean) {
        this.pageBean = pageBean;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public ContentTypeService getContentTypeService() {
        return ContentTypeService;
    }

    public void setContentTypeService(ContentTypeService ContentTypeService) {
        this.ContentTypeService = ContentTypeService;
    }

    public List<ContentType> getAllContentType() {
        return allContentType;
    }

    public void setAllContentType(List<ContentType> allContentType) {
        this.allContentType = allContentType;
    }

    public ContentType getContentType() {
        return contentType;
    }

    public void setContentType(ContentType contentType) {
        this.contentType = contentType;
    }
    
    
    
    public String main() throws Exception {
        return "success";
    }

   
    public String ctypelist() throws Exception {

        pageBean = ContentTypeService.getPageBean(page, pageSize, contentType);

        return SUCCESS;
    }
    
     public void ctypeDeleteById() {
        
        ContentTypeService.delById(contentType.getId());
        
    }

    public String addCTypeInput() throws Exception {
        actionURI = "cTypesave";
        return SUCCESS;
    }

    public String cTypesave() throws Exception {
        ContentTypeService.save(contentType);
        return SUCCESS;
    }
    
      
      public String update() throws Exception {
        this.ContentTypeService.update(contentType);
        return SUCCESS;
    }
    
    public String updateInput() throws Exception {
        actionURI = "ctypeUpdate";
        contentType = this.ContentTypeService.get(contentType.getId());
        if(contentType == null)
            return ERROR;
        else
            return SUCCESS;
    }
}
